<template>
	<!-- 常用审批语 -->
	<view class="word">
		<block v-if="wordOptions.length">
			<view :class="['word_lists',wordIndex == index ? 'word_selected' : '']" v-for="(item,index) in wordOptions" :key="index" @click="getValue(index)">
				<view class="word_list">
					{{ item.text || item.title }}
				</view>
			</view>
		</block>
		<u-empty v-else></u-empty>
	</view>
</template>
<script>
	import { initDictOptions } from '@/utils/JDictSelectUtil.js'
	export default {
		data() {
			return {
				eventChannel: null,
				wordOptions: [],
				wordIndex: null
			}
		},
		onLoad() {
			// #ifdef APP-NVUE
					this.eventChannel = this.$scope.eventChannel; // 兼容APP-NVUE
			  // #endif
			  // #ifndef APP-NVUE
					this.eventChannel = this.getOpenerEventChannel();
			  // #endif
			// 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据
			// this.eventChannel.on('acceptDataFromOpenerPage', function(data) {
			// 	that.model = { ...data }
			// })
			this.initDictConfig()
		},
		methods: {
			initDictConfig() {
				//初始化字典 - 性别
				initDictOptions('approval_remarks').then((res) => {
					if (res.success) {
						this.wordOptions = res.result;
					}
				});
			},
			getValue(index){
				this.wordIndex = index
				// 将数据传送回上一个页面
				this.eventChannel.emit('acceptDataFromOpenedPage', this.wordOptions[index].text || this.wordOptions[index].title)
				uni.navigateBack()
			}
		}
	}
</script>
<style lang="scss" scoped>
.word{
	width: 100%;
	height: 100%;
	background-color: #fff;
	.word_lists{
		padding: 0 32rpx;
		.word_list{
			font-size: 32rpx;
			font-weight: 400;
			padding: 34rpx 0;
			color: #7F7F7F;
			line-height: 44rpx;
			border-bottom: 1px solid rgba(0,0,0,0.05);
		}
	}
	.word_selected{
		background-color: rgba(0,0,0,0.05);
	}
}
</style>